<?php
namespace app\http;

use think\worker\Server;

class Worker extends Server
{
	// protected $socket = 'ws://0.0.0.0:2346';

     /**
     * 收到信息
     * @param $connection
     * @param $data
     */
	public function onMessage($connection, $data)   //收到客户端发送过来的请求
    {
        $connection->send('我收到你的信息了'); 
    }

     /**
     * 当连接建立时触发的回调函数
     * @param $connection
     */
	public function onConnect($connection)
    {
        $connection->send('已建立连接');
    }
    /**
     * 当连接断开时触发的回调函数
     * @param $connection
     */
    public function onClose($connection)
    {
        $connection->send('连接断开');
    }
     /**
     * 当客户端的连接上发生错误时触发
     * @param $connection
     * @param $code
     * @param $msg
     */
    public function onError($connection, $code, $msg)
    {
        echo "error $code $msg\n";
    }
    /**
     * 每个进程启动
     * @param $worker
     */
	public function onWorkerStart($worker)
    {
        $inner_text_worker = new \Workerman\Worker('Text://127.0.0.1:5678');
	}
	// public function onWorkerStart($worker){
	// 	$handle = new Index();
	// 	$handle -> add_timer();//定时计划
		
	// }

}